package com.lixun.passwordbook.util;

import ohos.app.Context;
import ohos.data.DatabaseHelper;
import ohos.data.preferences.Preferences;

public class FileData {
    private static final String filename = "ahyyagyyh";

    private Preferences getFileData(Context context) {
        DatabaseHelper databaseHelper1 = new DatabaseHelper(context);
        return databaseHelper1.getPreferences(filename);
    }

    public void setBoolean (Context context, String name, boolean value){
        Preferences preferences = getFileData(context);
        preferences.putBoolean(name,value);
        preferences.flush();
    }

    public boolean getBoolean (Context context, String name, boolean value){
        Preferences preferences = getFileData(context);
        return preferences.getBoolean(name,value);
    }
    public void setString (Context context, String name, String value){
        Preferences preferences = getFileData(context);
        preferences.putString(name,value);
        preferences.flush();
    }

    public String getString (Context context, String name, String value){
        Preferences preferences = getFileData(context);
        return preferences.getString(name,value);
    }



}
